const Koa = require('koa');
const path = require('path');
const app = new Koa();
const Router = require('koa-router');
const router = new Router()
const submitRouter = require('./router/submit')
const answerRouter = require('./router/answer')

const static = require('koa-static');

app.use(static(path.resolve('public')));

// 加载子路由
router.use('/submit', submitRouter.routes(), submitRouter.allowedMethods());
router.use('/answer', answerRouter.routes(), answerRouter.allowedMethods());

// 加载路由中间件
app.use(router.routes()).use(router.allowedMethods());


app.listen(3000, () => {
    console.log('port is 3000');
});